<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;


/**
 * 后台首页控制器
 * 主要获取首页聚合数据
 */
class ProductmanagementController extends AdminController {
    
	//展位管理
	public function product_management(){
        $map = array();
        //$map  = array('status' => 1);
        $name=I('name');
		if(is_numeric($name)){
			$map['id|name']=array(intval($name),array('like','%'.$name.'%'),'_multi'=>true);//'_multi'=>true表示多条件匹配
		}else{
		    $map['name']=array('like','%'.(string)$name.'%');
		}
		
		$lists = $this->lists('Product_info',$map,'id asc');
		//$lists  = D('Product_info')->where($map)->order('id asc')->select();//查询语句
    	$this->assign('productmanagement',$lists);
	 
	    $this->display();
	}

	//产品审核
	public function product_review(){
		$map = array();
        //$map  = array('status' => 1);
        $name=I('name');
		if(is_numeric($name)){
			$map['id|name']=array(intval($name),array('like','%'.$name.'%'),'_multi'=>true);//'_multi'=>true表示多条件匹配
		}else{
		    $map['name']=array('like','%'.(string)$name.'%');
		}
		
		$lists = $this->lists('Product_info',$map,'id asc');
		//$lists  = D('Product_info')->where($map)->order('id asc')->select();//查询语句
    	$this->assign('productmanagement',$lists);
	 
	    $this->display();
	}

	//删除操作
	public function del(){
		$id=array_unique((array)I('id',0));
		if(empty($id)){
			$this->error('请输入数据!');

		}
		$where=array('id'=>array('in',$id));
		if(M('Product_info')->where($where)->delete()){
			S('DB_CONFIG_DATA',null);
			//记录行为
			action_log('update_config','Product_info',$id,id);
			$this->success('删除成功');
		}else{
			$this->error('删除失败');
		}
	}

	//屏蔽，开启，删除
	public function changestatus($method=null){
		$id=array_unique((array)I('id',0));
		$id=is_array($id) ? implode(',',$id) : $id;
		if(empty($id)){
			$this->error('请选择要操作的数据');
		}
		$where['id']=array('in',$id);
		switch(strtolower($method)){
			case 'forbidproduct':
				$this->forbid('Product_info',$where);
				break;
			case 'resumeproduct':
				$this->resume('Product_info',$where);
				break;
			case 'deleteproduct':
				$this->delete('Product_info',$where);
				break;
			default:
				$this->error('非法参数');
		}

	}

}




?>